﻿<%@ Page Title="Quản lí quận, huyện" Language="C#" MasterPageFile="~/Views/MasterPageViews.master" AutoEventWireup="true"
    CodeFile="LocationDistricts.aspx.cs" Inherits="Views_LocationDistricts" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<asp:Content ID="ContentHeader" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="ContentChange" ContentPlaceHolderID="ContentPlaceHolderChange" runat="Server">
    <h3 class="header-title">
        <ext:Label StyleHtmlCls="lable-message" StyleHtmlContent="true" ID="lblHeader" runat="server" Text="Quản lí quận huyện"
            Icon="ApplicationFormMagnify" />
    </h3>
    <div class="content-sub">
        <ext:Toolbar ID="ToolbarFunctions" runat="server">
            <Items>
                <ext:Button ID="btnToobarAdd" runat="server" Text="Thêm mới" Icon="Add" OnDirectClick="btnToobarAdd_DirectClick" />
                <ext:Button ID="btnToobarUpdate" runat="server" Text="Chỉnh sửa" Icon="Pencil" OnDirectClick="btnToobarUpdate_DirectClick" />
                <ext:Button ID="btnToobarDelete" runat="server" Text="Xóa" Icon="Delete" OnDirectClick="btnToobarDelete_DirectClick" />
                <ext:Button ID="btnToobarHelp" runat="server" Text="Hỗ trợ" Icon="Help" />
            </Items>
        </ext:Toolbar>
        <!--Store for provice gridpanel-->
        <ext:Store
            ID="StoreDist"
            runat="server"
            OnReadData="StoreDist_ReadData"
            PageSize="30">
            <Sorters>
                <ext:DataSorter Direction="ASC" Property="NameOfDist" />
            </Sorters>
            <Model>
                <ext:Model ID="ModelDist" runat="server" IDProperty="DistID">
                    <Fields>
                        <ext:ModelField Name="DistID" />
                        <ext:ModelField Name="NameOfDist" />
                        <ext:ModelField Name="StatusDist" Type="Boolean" />
                        <ext:ModelField Name="NameOfProvince" />
                    </Fields>
                </ext:Model>
            </Model>
        </ext:Store>
        <!----------------->
        <!--Grid province-->
        <ext:GridPanel
            ID="GridPanelDist"
            runat="server"
            StoreID="StoreDist"
            Title="Danh sách quận huyện"
            Height="510"
            Split="true"
            AutoScroll="True" 
            BodyStyle="background-image: url('../Themes/bg-main.png')">
            <ColumnModel ID="ColumnModelPDist" runat="server">
                <Columns>
                    <ext:RowNumbererColumn ID="RowNumbererColumnProvince" Width="30" Text="STT" runat="server" />
                    <ext:Column ID="Col_ID" runat="server" Text="Mã quận huyện" DataIndex="DistID" Hidden="true" />
                    <ext:Column ID="Col_Name" runat="server" Text="Quận Huyện" DataIndex="NameOfDist" Flex="1" />
                    <ext:CheckColumn ID="Col_Status" runat="server" Text="Trạng thái" DataIndex="StatusDist" />
                    <ext:Column ID="Col_ProvinceName" runat="server" Text="Tỉnh thành" DataIndex="NameOfProvince" />
                </Columns>
            </ColumnModel>

            <SelectionModel>
                <ext:RowSelectionModel ID="RowSelectionModelDist" runat="server" Mode="Single">
                    <DirectEvents>
                        <Select OnEvent="RowSelect" Buffer="250" />
                    </DirectEvents>
                </ext:RowSelectionModel>
            </SelectionModel>
            <BottomBar>
                <ext:PagingToolbar ID="PagingToolbarDist" runat="server" StoreID="StoreDist" BeforePageText="Trang"
                    EmptyMsg="Chưa có dữ liệu" AfterPageText="trên  {0}"
                    DisplayMsg="Hiển thị bản ghi {0} - {1} trên tổng số {2}" RefreshText="Làm mới" LastText="Trang cuối"
                    NextText="Trang kế" PrevText="Trang trước" FirstText="Trang đầu" />
            </BottomBar>
        </ext:GridPanel>
        <!--------------------->

    </div>
    <!------>
    <div class="view-info-record">
        <h3 class="header-title">
            <ext:Label StyleHtmlCls="lable-message" StyleHtmlContent="true" ID="lblDistHead" runat="server" Text="Hiển thị thông tin quận huyện"
                Icon="Information" />
        </h3>
        <div class="content-info">
            <table>
                <tr>
                    <td class="with-td-view-info">ID:</td>
                    <td>
                        <ext:Label ID="lblViewDistID" runat="server" />
                    </td>
                </tr>
                <tr>
                    <td class="with-td-view-info">Quận Huyện:</td>
                    <td>
                        <ext:Label ID="lblViewNameOfDist" runat="server" />
                    </td>
                </tr>
                <tr>
                    <td class="with-td-view-info">Tỉnh thành:</td>
                    <td>
                        <ext:Label ID="lblViewProName" runat="server" />
                    </td>
                </tr>
                <tr>
                    <td class="with-td-view-info">Trạng thái:</td>
                    <td>
                        <ext:Checkbox ID="chkViewDistStatus" runat="server" />
                    </td>
                </tr>
            </table>
        </div>
    </div>
    <!------------------->
    <!-- Cửa sổ popup Thêm mới quận huyện-->
    <ext:Window
        ID="windowAddDistrict"
        runat="server"
        Title="Thêm mới quận huyện"
        Icon="Add"
        Height="200"
        Width="350"
        BodyStyle="background-color: #fff;"
        Modal="true"
        ShadowMode="Drop"
        Hidden="true">
        <Content>
            <ext:Toolbar ID="ToolbarAddDistrict" runat="server">
                <Items>
                    <ext:Button ID="btnAdd" runat="server" Text="Thêm mới" Icon="Disk">

                        <Menu>
                            <ext:Menu ID="MenuAddDistButton" runat="server">
                                <Items>
                                    <ext:MenuItem ID="menuItemAddDist" runat="server" Text="Thêm mới" Icon="DiskBlack" OnDirectClick="menuItemAddDist_DirectClick" />
                                    <ext:MenuItem ID="menuItemAddDistAndClose" runat="server" Text="Thêm và đóng" Icon="DiskBlack" OnDirectClick="menuItemAddDistAndClose_DirectClick" />
                                </Items>
                            </ext:Menu>
                        </Menu>
                    </ext:Button>
                    <ext:Button ID="btnAddCancel" runat="server" Text="Hủy bỏ" Icon="Delete" OnDirectClick="btnAddCancel_DirectClick" />
                </Items>
            </ext:Toolbar>
            <div class="content-popup-style">
                <div class="view-msg-popup">
                    <ext:Label ID="lblFormAddDistrict" runat="server" Text="Ok" StyleHtmlContent="True" Icon="None" Cls="lable-message-error" />
                </div>
                <div>
                    <ext:SelectBox
                        ID="cbxProvinces"
                        runat="server"
                        DisplayField="NameOfProvince"
                        ValueField="ProvID"
                        EmptyText="Lựa chọn"
                        FieldLabel="Tỉnh thành"
                        Width="310"
                        MarginSpec="5 0 5 0">
                        <Store>
                            <ext:Store ID="storeProvince" runat="server">
                                <Model>
                                    <ext:Model ID="modelProvince" runat="server">
                                        <Fields>
                                            <ext:ModelField Name="ProvID" />
                                            <ext:ModelField Name="NameOfProvince" />
                                        </Fields>
                                    </ext:Model>
                                </Model>
                            </ext:Store>
                        </Store>
                    </ext:SelectBox>
                    <ext:TextField ID="txtFormAddName" runat="server" FieldLabel="Tên quận huyện" Width="310" MarginSpec="5 0 5 0" />
                    <ext:Checkbox ID="chkFormAddStatus" runat="server" FieldLabel="Trạng thái" BoxLabel="Cho phép hoạt động" />
                </div>
            </div>
        </Content>
    </ext:Window>
    <!-- Cửa sổ popup cập nhật thông tin quận huyện-->
    <ext:Window
        ID="WindownUpdateDist"
        runat="server"
        Title="Chỉnh sửa thông quận huyện"
        Icon="Pencil"
        Height="200"
        Width="350"
        BodyStyle="background-color: #fff;"
        Modal="true"
        ShadowMode="Drop"
        Hidden="true">
        <Content>
            <ext:Toolbar ID="ToolbarUpdateDist" runat="server">
                <Items>
                    <ext:Button ID="btnUpdateDist" runat="server" Text="Hoàn thành" Icon="Disk" OnDirectClick="btnUpdateDist_DirectClick" />
                    <ext:Button ID="btnCancelUpdateDist" runat="server" Text="Hủy bỏ" Icon="Delete" OnDirectClick="btnCancelUpdateDist_DirectClick" />
                </Items>
            </ext:Toolbar>
            <div class="content-popup-style">
                <div class="view-msg-popup">
                    <ext:Label ID="lblFormUpdateDist" runat="server" Text="Ok" StyleHtmlContent="True" Icon="None" Cls="lable-message-error" />
                </div>
                <div>
                    <ext:SelectBox
                        ID="cbxUpdateDistProvine"
                        runat="server"
                        DisplayField="NameOfProvince"
                        ValueField="ProvID"
                        EmptyText="Lựa chọn"
                        FieldLabel="Tỉnh thành"
                        Width="310"
                        MarginSpec="5 0 5 0">
                        <Store>
                            <ext:Store ID="StoreFormUpdateDist" runat="server">
                                <Model>
                                    <ext:Model ID="ModelUpdateDist" runat="server">
                                        <Fields>
                                            <ext:ModelField Name="ProvID" />
                                            <ext:ModelField Name="NameOfProvince" />
                                        </Fields>
                                    </ext:Model>
                                </Model>
                            </ext:Store>
                        </Store>
                    </ext:SelectBox>
                    <ext:TextField ID="txtFormUpdateDistName" runat="server" FieldLabel="Tên quận huyện" Width="310" MarginSpec="5 0 5 0" />
                    <ext:Checkbox ID="chkFormUpdateDistStatus" runat="server" FieldLabel="Trạng thái" BoxLabel="Cho phép hoạt động" />
                </div>
            </div>
        </Content>
    </ext:Window>
    <!-- Gird-View Scripts -->
    <script>
        var template = '<span style="color:{0};">{1}</span>';

        var change = function (value) {
            return Ext.String.format(template, (value > 0) ? "green" : "red", value);
        }

        var pctChange = function (value) {
            return Ext.String.format(template, (value > 0) ? "green" : "red", value + "%");
        }
    </script>
</asp:Content>
